//
//  companyViewController.m
//  Park
//
//  Created by 123456 on 2017/11/29.
//  Copyright © 2017年 YTYangK. All rights reserved.
//

#import "companyViewController.h"
#import "companyCollectionViewCell.h"
#import "RosterViewController.h"
@interface companyViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
/**
 *  图片数组
 */
@property (nonatomic, strong) NSMutableArray *imageArray;


@end

@implementation companyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.


    [self.companycollection registerNib:[UINib nibWithNibName:@"companyCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"cell"];

    for (int i =1; i<=6; i++) {
        [self.imageArray addObject:[NSString stringWithFormat:@"公司%d",i]];
    }
}


//collectionview代理方法
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    companyCollectionViewCell *cell =  [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    
    
    cell.companyimage.image = [UIImage imageNamed:self.imageArray[indexPath.row]];
    
    
    return cell;
    
}

//collectionview的显示
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 6;
}

//大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    return CGSizeMake(self.companycollection.size.width/2-20, self.companycollection.size.height/3-30);
}

//选中状态
-( void )collectionView:( UICollectionView *)collectionView didSelectItemAtIndexPath:( NSIndexPath *)indexPath{
    
    RosterViewController *r =[[RosterViewController alloc]init];
    [self.navigationController pushViewController:r animated:YES];

    
}

-(NSMutableArray *)imageArray
{
    if (!_imageArray) {
        _imageArray = [[NSMutableArray alloc]init];
    }
    return _imageArray;
}


@end
